package com.fourth.dto;

import com.fourth.enums.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Created with IntelliJ IDEA.
 *
 *
 * @author 邓建波
 */
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    private Integer code;
    private String message;
    private Object data;

    public Result(ResultCode resultCode){
        this.code = resultCode.getCode();
        this.message = resultCode.getMsg();
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Result ok(){ return new Result(ResultCode.SUCCESS);}
    public static Result ok(String message){return new Result(200,message);}
    public static Result ok(String message, Object data){return new Result(200,message,data);}
    public static Result fail(){return new Result(ResultCode.FAIL);}
    public static Result fail(String message){return new Result(400,message);}
    public static Result fail(String message, Object data){return new Result(400,message,data);}

}
